#ifndef _FUNC_H
#define _FUNC_H

#include <stdint.h>

int startsWith(const char *str, const char *prefix);
int exist_file(const char* fn);
// unit M
void get_process_rss(float* VmSize, float* VmRSS);

#define COST(U) (U == 'G' ? 1024*1024*1024 : U == 'M' ? 1024*1024 : U == 'K' ? 1024 : 1)
uint64_t __to_unit(uint64_t size, char* unit);

#define FACTOR(x) ((x) == 1 ? 10 : (x) == 2 ? 100 : (x) == 3 ? 1000 : (x) == 4 ? 10000 : 1)
#define D_DECIMAL(x, n) ((x) = ((int64_t)((x)*FACTOR(n))) * 1.0 / FACTOR(n))

#endif
